//不要给我WA WA 叫
//一定AC
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <iomanip>
#include <climits>
#define int long long 
#define x first 
#define y second 
using namespace std;
const int N = 1e5 + 10;
int a[N];
const int MOD = 1e9 + 7;
// 快速幂算法
int qmi(int a,int b,int p)
{
    int res=1%p;
    while(b)
    {
        if(b&1) res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return res;
}
int gcd(int a,int b)
{
    while(a%b)
    {
        int c = a % b;
        a = b;
        b = c;
    }
    return b;
}
int lcm(int a, int b) 
{
    return (a / gcd(a, b)) * b;
}
int f(int l,int r)
{
    int tol = 0;
    for(int i = l; i < r; i++)
    {
        int x = qmi(i , i , MOD);
        int y = qmi(i + 1, i + 1, MOD);
        tol = (tol + (x * y)) % MOD;
    }
    return tol;
}
void solve()
{
    int l,r;
    cin >> l >> r;
    cout << f(l,r) << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
    while(t -- )  solve();
    return 0;
}
